<template>
  <section>
    <h2>子传父：子组件</h2>
    <input v-model="name"/>
    <button @click="handleClick">按钮</button>
  </section>
</template>

<script>

import {ref} from "vue";

export default {
    // setup的第二个参数：上下文对象
    setup(props,context) {
        const name = ref("");

        console.log("context = ",context);

        function handleClick() {
            context.emit("sendData",name.value);
        }

        return {
            name,handleClick
        }
    }
};
</script>

<style>
</style>